package deng.ejbtx.ejb.tx;

import java.io.File;

import javax.annotation.PostConstruct;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.jms.MessageListener;

import deng.ejbtx.ejb.GroovyMsgBean;


@MessageDriven(
		messageListenerInterface = MessageListener.class,
		activationConfig = { 
			@ActivationConfigProperty(					
				propertyName = "destination", propertyValue = "queue/ExampleQueue"),
			@ActivationConfigProperty(					
				propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
			@ActivationConfigProperty(					
				propertyName = "messageSelector", propertyValue = "") 
		})
public class MDBTxBean1 extends GroovyMsgBean {
	@EJB(beanName="TxBean2")
	private TxBean txBean2;
	
	@EJB(beanName="TxBean3")
	private TxBean txBean3;
	
	@PostConstruct
	public void init() {
		File script = new File(System.getProperty("user.home") + "/scripts/" + getClass().getName() + ".groovy");
		setScriptFile(script);
		initGroovyEngine();
	}
	
	public TxBean getTxBean2() {
		return txBean2;
	}
	public TxBean getTxBean3() {
		return txBean3;
	}
}
